#ifndef PEER_GROUP_H
#define PEER_GROUP_H

#include "node.h"
#include "port.h"
#include "channel.h"

#include "ip/peer.h"

#include "ip/mrunner.h"

#include "ip/fabrics.h"

#include "ip/router_nanoop.h"

#include "ip/router_load.h"

#include "ip/arbiter_store.h"

#include "ip/and_gate.h"

typedef struct NodePeerGroupParam
{
    int peer_id_base;
    int num_of_peer;
    int softmem_size;
    int num_of_main_memory;
    int num_of_alu;
    int multiplexer;
    int total_peers;
    List<int> base_ptrs;
} NodePeerGroupParam;

class NodePeerGroup : public Node
{
public:
    List<int> const_peer_ids;
    ChannelLoadFabricSender * port_chain_out;
    ChannelLoadFabricReceiver * port_chain_in;
    ChannelExecOpFabricReceiver * port_nano_op_receiver;
    List<ChannelLoadFabricReceiver *> port_memory_receivers;
    List<ChannelStoreFabricSender *> port_memory_senders;
    PortOut<bool> * port_halt;
    List<NodePeer *> node_peers;
    NodeMRunner * node_mrunner;
    NodeRouterNanoOp * node_router_eop;
    List<NodeRouterLoad *> node_router_load;
    List<NodeArbiterStore *> node_arbiter_store;
    NodeAndGate * node_halt_detect;

    NodePeerGroup(Node *parent, NodePeerGroupParam params);
    NodeTaskList tasks() const override;
};

#endif // PEER_GROUP_H